<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
  <title>系统常态化运行评分系统</title>
  <link rel="stylesheet" href="../component/pear/css/pear.css" />
</head>

<body class="pear-container">
<div class="layui-card">
  <div class="layui-card-header">密码修改</div>
  <div class="layui-card-body">
    <form class="layui-form" action="" onsubmit="return false" lay-filter="lay-info">
      <div class="layui-form-item">
        <div class="layui-form-label">用户名称</div>
        <div class="layui-input-block">
          <input type="text"  name="userName"  disabled="disabled"  placeholder="用户名称" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">登录账号</label>
        <div class="layui-input-block">
          <input type="text" name="loginName" disabled="disabled" placeholder="任务名称" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
          <label class="layui-form-label">用户角色</label>
          <div class="layui-input-block">
            <input type="text" name="roleName" disabled="disabled" placeholder="任务名称" autocomplete="off" class="layui-input">
          </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">原密码</label>
        <div class="layui-input-block">
          <input type="password" name="oldPassword" lay-verify="password"  placeholder="原密码" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-block">
          <input type="password" name="newPassword"  lay-verify="password" placeholder="原密码" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">新密码确认</label>
        <div class="layui-input-block">
          <input type="password" name="newPasswordConfire"  lay-verify="password" placeholder="原密码" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="pear-btn pear-btn-primary" lay-submit lay-filter="lay-modify-login-pwd">修改系统登录密码</button>
        </div>
      </div>
    </form>
  </div>
</div>
<script src="../component/layui/layui.js"></script>
<script src="../component/pear/pear.js"></script>
<script src="../scripts/utils/request.js"></script>
<script src="../scripts/utils/auth.js"></script>
<script>
  var $,table,form,drawer,popup,notice,laydate,hashes
  layui.use(['table', 'form', 'jquery', 'drawer', 'popup','notice','laydate','hashes'], function() {
    table = layui.table;
    form = layui.form;
    $ = layui.jquery;
    drawer = layui.drawer;
    popup = layui.popup;
    notice = layui.notice;
    laydate= layui.laydate;
    hashes= layui.hashes;

    //请求接口获取个人基本信息（主要是根据需要获取评分密码）

    postAjaxNoSuccessTip('/api/user/getUserInfo',null,function (response){
      form.val('lay-info', {
        "userName": response.data.userName,
        "roleName": response.data.roleTypeName,
        "loginName": response.data.loginName,
        "mineCheckPassword":response.data.mineCheckPassword
      });
    },null);


    form.on('submit(lay-modify-login-pwd)', function (data) {
      if(data.field.newPasswordConfire!=data.field.newPassword){
        notice.error("两次密码输入不一致！");
        return false;
      }
      let reqData=data.field;
      reqData.newPassword= btoa(reqData.newPassword)
      reqData.oldPassword= btoa(reqData.oldPassword)
      postAjax('/api/user/modifyLoginPwd',reqData,function (response){

      },null);
    });
    // 自定义验证规则
    form.verify({
      password: function (value) {
        if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@#$%^&+=!])(?!.*\s).{4,50}$/.test(value)) {
          return '请输入正确的密码格式（ps:至少包含大写字母、数字、特殊符号）';
        }
      }
    });


  });
</script>
</body>
</html>